<?php
class TinymceHelper extends Helper {
	
	var $name = 'Tinymce';
	
	function load($id, $type=1, $width=500, $height=350, $skin="o2k7") {
		$str = '';
		if($type==1) {
			$str = '
				<script type="text/javascript">
				tinyMCE.init({
					mode :"exact",
					elements: "'.$id.'",
					height :"'.$height.'",
					width :"'.$width.'",
					skin : "'.$skin.'",
					theme : "advanced",
					plugins : "media",
					theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink,image,media,anchor,formatselect",
					theme_advanced_buttons2 : "",
					theme_advanced_buttons3 : "",
					theme_advanced_toolbar_location : "top",
					theme_advanced_toolbar_align : "left",
					extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
				});
				</script>
			';
			return $str;
		}
		
		if($type==2) {
			$str = '
				<script type="text/javascript">
				tinyMCE.init( {
						mode :"exact",
						elements: "'.$id.'",
						height :"'.$height.'",
						width :"'.$width.'",
						skin : "'.$skin.'",
						theme :"advanced",
						plugins :"table,advhr,advlink,emotions,inlinepopups,preview,contextmenu,fullscreen,noneditable,visualchars,nonbreaking,advimage",
						// Theme options
						theme_advanced_buttons1 :"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect,|,bullist,numlist,|,forecolor,backcolor,outdent,indent",
						theme_advanced_buttons2 :"link,unlink,anchor,image,cleanup,|,tablecontrols,|,hr,removeformat,|,sub,sup,|,charmap,emotions,advhr,|,code,fullscreen",
						theme_advanced_buttons3 :"",
						theme_advanced_toolbar_location :"top",
						theme_advanced_toolbar_align :"left",
						theme_advanced_statusbar_location :"bottom",
						theme_advanced_resize_horizontal :false,
						theme_advanced_resizing :true,
						file_browser_callback : "ajaxfilemanager",
						apply_source_formatting :true,
						convert_urls :false,
						relative_urls :false
					}
				);
				function ajaxfilemanager(field_name, url, type, win) {
					var ajaxfilemanagerurl = "'.$this->webroot.'js/tiny_mce_3.3.8/plugins/ajaxfilemanager/ajaxfilemanager_dtadmin.php";
					switch (type) {
						case "image":
							break;
						case "media":
							break;
						case "flash": 
							break;
						case "file":
							break;
						default:
							return false;
					};
					tinyMCE.activeEditor.windowManager.open({
							url: "'.$this->webroot.'js/tiny_mce_3.3.8/plugins/ajaxfilemanager/ajaxfilemanager_dtadmin.php",
							width: 782,
							height: 440,
							inline : "yes",
							close_previous : "no"
					},{
							window : win,
							input : field_name
					})
				};
			</script>
			';
			return $str;
		}
	}
}
?>